#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N_MAX 200
#define M_MAX 200

int
main(void)
{
	int  map[N_MAX+2][M_MAX+2];
	char in_map[N_MAX+2][M_MAX+2], c;
	register int  n, m, i, j;

	freopen("mines.in", "rt", stdin);
	freopen("mines.out", "w", stdout);

	scanf("%d %d\n", &n, &m);
	for (i = 1; i <= n; ++i) {
		for (j = 1; j <= m; ++j) {
			if (c = getchar(), (c != '\n' && c != EOF))
				in_map[i][j] = c;
			if (c == '\n')
				--j;
		}
	}
	memset(map, 0, sizeof(map));

	for (i = 1; i <= n; ++i) {
		for (j = 1; j <= m; ++j) {
			if (in_map[i-1][j-1] == '*')
				++map[i][j];
			if (in_map[i-1][j] == '*')
				++map[i][j];
			if (in_map[i-1][j+1] == '*')
				++map[i][j];
			if (in_map[i][j-1] == '*')
				++map[i][j];
			if (in_map[i][j+1] == '*')
				++map[i][j];
			if (in_map[i+1][j-1] == '*')
				++map[i][j];
			if (in_map[i+1][j] == '*')
				++map[i][j];
			if (in_map[i+1][j+1] == '*')
				++map[i][j];
		}
	}

	for (i = 1; i <= n; ++i) {
		for (j = 1; j <= m; ++j) {
			if (in_map[i][j] == '*')
				putchar('*');
			else if (map[i][j] > 0)
				printf("%d", map[i][j]);
			else
				putchar('.');
		}
		putchar('\n');
	}
}
